package com.mc.ssm.book.service.impl;

import com.mc.ssm.book.dao.BookDao;
import com.mc.ssm.book.model.Book;
import com.mc.ssm.book.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by zhangzhenguo on 2017/2/11.
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDao bookDao;

    public int saveBook(Book book) {
        return bookDao.saveBook(book);
    }

    public int updateBook(Book book) {
        return bookDao.updateBook(book);
    }

    public int deleteBook(long id) {
        return bookDao.deleteBookById(id);
    }

    public List<Book> selectBooksByName(String bookName) {
        return bookDao.selectBooksByName(bookName);
    }

    public List<Book> findAllBooks() {
        return bookDao.selectAllBooks();
    }

    public Book findBookById(long bookId) {
        return bookDao.selectBookById(bookId);
    }
}
